package cn.itsource.org.service.impl;

import cn.itsource.basic.service.impl.BaseServiceImpl;
import cn.itsource.org.domain.Employee;
import cn.itsource.org.mapper.EmployeeMapper;
import cn.itsource.org.query.EmployeeQuery;
import cn.itsource.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author CTL
 * @Description
 * @date Created in 2023-05-16 14:17
 */
@Service
public class EmployeeServiceImpl extends BaseServiceImpl<Employee,EmployeeQuery> implements IEmployeeService {

    @Autowired
    private EmployeeMapper mapper;

    //分页查询
    //@Override
    //public PageList<Employee> getPageList(EmployeeQuery query) {
    //    //1.设置分页参数
    //    PageHelper.startPage(query.getPageNum(),query.getPageSize());
    //    //2.执行查询操作
    //    List<Employee> list = mapper.selectAll();
    //    //3.封装分页数据
    //    PageInfo<Employee> PageInfo = new PageInfo<>(list);
    //    //4.使用自己的工具类返回分页数据
    //    PageList<Employee> PageList = new PageList<Employee>(PageInfo.getTotal(),PageInfo.getList());
    //    //5.返回数据
    //    return PageList;
    //}

    //添加，修改
    //@Override
    //@CacheEvict(cacheNames="emp",key="'manger'")
    //public void addOrUpdate(Employee employee) {
    //    if(employee.getId()==null){
    //        //没有id,添加
    //        mapper.insertSelective(employee);
    //    }else {
    //        //有id,修改
    //        mapper.updateByPrimaryKeySelective(employee);
    //    }
    //}

    //根据id删除
    //@Override
    //public void delete(Long id) {
    //    mapper.deleteByPrimaryKey(id);
    //}
    //
    //@Override
    //public List<Employee> getAll() {
    //    return mapper.selectAll();
    //}

    //部门经理
    @Override
    @Cacheable(cacheNames="emp",key="'manger'")
    public List<Employee> getAllDepaManger() {
        return mapper.getAllDepaManger();
    }
}
